home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / gfx / show / gs_src_gs.lha / gs5.03 / ialloc.h < prev    next >
C/C++ Source or Header  |  1995-05-27  |  4KB  |  118 lines

  1. /* Copyright (C) 1989, 1995 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* ialloc.h */
  20. /* Interface to Ghostscript interpreter memory allocator */
  21.  
  22. #ifndef ialloc_INCLUDED
  23. #  define ialloc_INCLUDED
  24.  
  25. #include "imemory.h"
  26.  
  27. /*
  28.  * Define the interpreter memory manager instance.
  29.  */
  30. extern gs_dual_memory_t gs_imemory;
  31. #define idmemory (&gs_imemory)
  32. #define iimemory (gs_imemory.current)
  33. #define imemory ((gs_memory_t *)iimemory)
  34. #define iimemory_local (gs_imemory.space_local)
  35. #define imemory_local ((gs_memory_t *)iimemory_local)
  36. #define iimemory_global (gs_imemory.space_global)
  37. #define imemory_global ((gs_memory_t *)iimemory_global)
  38. #define iimemory_system (gs_imemory.space_system)
  39. #define imemory_system ((gs_memory_t *)iimemory_system)
  40.  
  41. /*
  42.  * Aliases for invoking the standard allocator interface.
  43.  */
  44. #define ialloc_bytes(nbytes, cname)\
  45.   gs_alloc_bytes(imemory, nbytes, cname)
  46. #define ialloc_struct(typ, pstype, cname)\
  47.   gs_alloc_struct(imemory, typ, pstype, cname)
  48. #define ialloc_byte_array(nelts, esize, cname)\
  49.   gs_alloc_byte_array(imemory, nelts, esize, cname)
  50. #define ialloc_struct_array(nelts, typ, pstype, cname)\
  51.   gs_alloc_struct_array(imemory, nelts, typ, pstype, cname)
  52. #define ifree_object(data, cname)\
  53.   gs_free_object(imemory, data, cname)
  54. #define ialloc_string(nbytes, cname)\
  55.   gs_alloc_string(imemory, nbytes, cname)
  56. #define ifree_string(data, nbytes, cname)\
  57.   gs_free_string(imemory, data, nbytes, cname)
  58.  
  59. /* Initialize the interpreter's allocator. */
  60. void ialloc_init(P3(gs_memory_t *, uint, bool));
  61.  
  62. /* Resize a string. */
  63. #define iresize_string(data, oldn, newn, cname)\
  64.   gs_resize_string(imemory, data, oldn, newn, cname)
  65.  
  66. /* ------ Internal routines ------ */
  67.  
  68. /* Reset the request values that identify the cause of a GC. */
  69. void ialloc_reset_requested(P1(gs_dual_memory_t *));
  70.  
  71. /* Validate the contents of memory. */
  72. void ialloc_validate_spaces(P1(const gs_dual_memory_t *));
  73. #define ivalidate_spaces() ialloc_validate_spaces(idmemory)
  74.  
  75. /*
  76.  * Local/global VM management.
  77.  */
  78.  
  79. /* Get the space attribute of the current allocator. */
  80. #define ialloc_space(dmem) ((dmem)->current_space)
  81. #define icurrent_space ialloc_space(idmemory)
  82. extern uint imemory_space(P1(gs_ref_memory_t *));
  83.  
  84. /* Select the allocation space. */
  85. void ialloc_set_space(P2(gs_dual_memory_t *, uint));
  86.  
  87. /*
  88.  * Ref-related facilities.
  89.  */
  90.  
  91. #ifdef r_type                /* i.e., we know about refs */
  92.  
  93. /* Allocate and free ref arrays. */
  94. #define ialloc_ref_array(paref, attrs, nrefs, cname)\
  95.   gs_alloc_ref_array(iimemory, paref, attrs, nrefs, cname)
  96. #define iresize_ref_array(paref, nrefs, cname)\
  97.   gs_resize_ref_array(iimemory, paref, nrefs, cname)
  98. #define ifree_ref_array(paref, cname)\
  99.   gs_free_ref_array(iimemory, paref, cname)
  100.  
  101. /* Allocate a string ref. */
  102. #define ialloc_string_ref(psref, attrs, nbytes, cname)\
  103.   gs_alloc_string_ref(iimemory, psref, attrs, nbytes, cname)
  104.  
  105. /* Make a ref for a newly allocated structure. */
  106. #define make_istruct(pref,attrs,ptr)\
  107.   make_struct(pref, (attrs) | icurrent_space, ptr)
  108. #define make_istruct_new(pref,attrs,ptr)\
  109.   make_struct_new(pref, (attrs) | icurrent_space, ptr)
  110. #define make_iastruct(pref,attrs,ptr)\
  111.   make_astruct(pref, (attrs) | icurrent_space, ptr)
  112. #define make_iastruct_new(pref,attrs,ptr)\
  113.   make_astruct_new(pref, (attrs) | icurrent_space, ptr)
  114.  
  115. #endif                    /* ifdef r_type */
  116.  
  117. #endif                    /* ialloc_INCLUDED */
  118.